//
//  main.m
//  Demo0013
//
//  Created by zTercel on 13-1-12.
//  Copyright (c) 2013年 zTercel. All rights reserved.
//

#import <Foundation/Foundation.h>

void NSMutableStringUsing()
{
    NSMutableString*   string    = [[NSMutableString alloc] initWithCapacity: 128];
    NSLog(@"after initWithcapcity: %@", string);
    [string appendString:@"this is a NSMutableString object"];
    NSLog(@"after appendString: %@", string);
    [string appendFormat:@" it length = %ld", [string length]];
    NSLog(@"after appendFormat: %@", string);
    NSRange range = [string rangeOfString:@"NSMutableString"];
    [string deleteCharactersInRange:range];
    NSLog(@"after deleteCharacters: %@", string);
    [string insertString:@"mutable string" atIndex:range.location];
    NSLog(@"after insertString: %@", string);
    [string setString: [string capitalizedString]];
    NSLog(@"perform capitalizedString: %@", string);
    NSInteger location = [string rangeOfString:@"= "].location;
    NSRange replaceRange = NSMakeRange(location, [string length] - location);
    NSString* stringLength = [[NSString alloc] initWithFormat:@"%ld", [string length]];
    [string replaceCharactersInRange: replaceRange withString:stringLength];
    NSLog(@"after replaceCharactersInRange: %@", string);
    [string setString:@"I reset it"];
    NSLog(@"after setString: %@", string);
    
    return;
}

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        NSMutableStringUsing();
        
    }
    return 0;
}

